package utils

import (
	"sort"
	"strings"
)

func SortString(s string) string {
	strs := strings.Split(s, "")
	sort.Strings(strs)
	sortedStr := strings.Join(strs, "")
	return sortedStr
}

func SwapArrayItem(nums []int, left, right int) {
	numLen := len(nums)
	if left < 0 || left > numLen-1 || right < 0 || right > numLen-1 {
		return
	}
	nums[left], nums[right] = nums[right], nums[left]
	return
}

func ReverseArray(nums []int) {
	leftPoint := 0
	rightPoint := len(nums) - 1
	for leftPoint < rightPoint {
		nums[leftPoint], nums[rightPoint] = nums[rightPoint], nums[leftPoint]
		leftPoint++
		rightPoint--
	}
	return
}
